/* 찜하기 표시 */ function makeshopWishlist() { this.my_wishlist = document.querySelectorAll('.my-wish-list'); this.my_wish_count = document.querySelectorAll('.my-wish-count'); this.my_catelist = document.querySelectorAll('.category-count'); this.my_catewish_count = document.querySelectorAll('.my-catewish-count'); this.isLogin = function () { return (document.cookie.indexOf('logincon=') > -1); } this.display = function (param) { var wishlist = []; for (var i=0; i -1) { if (this.my_wishlist[i].dataset.viewtype && this.my_wishlist[i].dataset.viewtype == 'block') { this.my_wishlist[i].classList.add('wish-on'); } else { this.enabled(this.my_wishlist[i]); } } else { if (this.my_wishlist[i].dataset.viewtype && this.my_wishlist[i].dataset.viewtype == 'block') { this.my_wishlist[i].classList.remove('wish-on'); } else { this.unenabled(this.my_wishlist[i]); } } } } this.display_cate = function (param) { var catelist = []; for (var i=0; i -1) { if (this.my_catelist[i].dataset.viewtype && this.my_catelist[i].dataset.viewtype == 'block') { if (typeof DESIGN_VIEW != 'undefined' && DESIGN_VIEW == 'RW') { this.my_catelist[i].classList.add("count-on"); } else if (icon) { icon.classList.remove("fa-heart-o"), icon.classList.add("fa-heart"); } } else { this.enabled(this.my_catelist[i]); } } else { if (this.my_catelist[i].dataset.viewtype && this.my_catelist[i].dataset.viewtype == 'block') { if (typeof DESIGN_VIEW != 'undefined' && DESIGN_VIEW == 'RW') { this.my_catelist[i].classList.remove("count-on"); } else if (icon) { icon.classList.remove("fa-heart"), icon.classList.add("fa-heart-o"); } } else { this.unenabled(this.my_catelist[i]); } } } } this.wishlist = function () { if (this.my_wishlist.length > 0) { if (this.isLogin()) { var _self = this; this.send(function (response) { if (response.result) { _self.display(response.data); } }, 'mode=wishlist'); } else { this.display([]); } } if (this.my_catelist.length > 0) { if (this.my_catelist.length == 1) { var wish_cate = this.my_catelist[0].dataset.code; } else { var wish_cate = []; for (let i = 0; i < this.my_catelist.length; i++) { wish_cate.push(this.my_catelist[i].dataset.code); } } if (this.isLogin()) { var _self = this; this.send(function (response) { if (response.result) { _self.display_cate(response.data); } }, 'mode=wishlist_cate&wish_cate='+wish_cate); } else { this.display_cate([]); } } } this.wishEvent = function () { var _self = this; for (var i=0; i 0) { fbq('track', 'AddToWishlist', {}, {eventID: response.pixel_event_id}); } } } else { if (response.message.length > 0) { alert(response.message); } } }, 'mode=wish&uid=' + this.dataset.uid); } }); } } this.enabled = function (el) { if (el.dataset.enabled !== undefined) { el.innerHTML = el.dataset.enabled; } else { el.parentElement.innerHTML = el.parentElement.dataset.enabled; } } this.unenabled = function (el) { if (el.dataset.unenabled !== undefined) { el.innerHTML = el.dataset.unenabled; } else { el.parentElement.innerHTML = el.parentElement.dataset.unenabled; } } this.observer = function () { if (typeof MutationObserver === 'function' && location.pathname.indexOf('/m/') > -1) { var _self = this; var wishlist_count = _self.my_wishlist.length; var wish_count = _self.my_wish_count.length; var mutationObserver = new MutationObserver(function() { _self.my_wishlist = document.querySelectorAll('.my-wish-list'); _self.my_wish_count = document.querySelectorAll('.my-wish-count'); if (wishlist_count !== _self.my_wishlist.length || wish_count !== _self.my_wish_count.length) { wishlist_count = _self.my_wishlist.length; wish_count = _self.my_wish_count.length; _self.init(); } }); mutationObserver.observe(document.body, { childList: true, subtree: true, }); } } this.send = function (action, data) { try { var xhr = new XMLHttpRequest(); xhr.open("POST", "/html/wishlist.action.html", true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function () { if (xhr.readyState === 4 && xhr.status === 200) { action(JSON.parse(xhr.responseText)); } } xhr.send(data); } catch (e) { console.log(e); } } this.wishCategory = function () { var _self = this; if (this.my_catewish_count.length > 0) { var codes = []; for (var i=0; i 0) { this.send(function (response) { if (response.result) { _self.wishCategoryCountDisplay(response.data); } }, 'mode=wish_category_count&codes=' + codes); } } } this.wishCategoryCountDisplay = function (param) { if (typeof param === 'object') { for (var i=0; i 0) { var uids = []; for (var i=0; i 0) { this.send(function (response) { if (response.result) { _self.wishCountDisplay(response.data); } }, 'mode=wish_count&uids=' + uids); } } } this.wishCountDisplay = function (param) { if (typeof param === 'object') { for (var i=0; i 0) { for (var i=0; i 0) { for (var i=0; i 0) ? parseInt(this.my_wish_count[i].innerHTML) - 1 : 0; } } } } this.init = function () { this.wishlist(); this.wishEvent(); //this.wishCount(); this.wishCategory(); } }